//
//  YYTopicDetailCollectionViewCell.swift
//  STMusic
//
//  Created by stoneobs on 17/5/10.
//  Copyright © 2017年 stoneobs. All rights reserved.
// //**********************话题详情collectionview cell***************************

import UIKit

class YYTopicDetailCollectionViewCell: UICollectionViewCell {
    
    var model:YYTopicMusicModel? = YYTopicMusicModel(){
    
        didSet{
        
            self.imageView?.sd_setImage(with: URL.init(string: (model?.works?.cover_photo)!), placeholderImage: BannerImage, options: .retryFailed);
            
            self.titlelabel?.text  = model?.works?.title;
            
            self.iconButton?.sd_setImage(with: URL.init(string: (model?.user_info?.avatar)!), for: .normal, placeholderImage: PeopleImage, options: .retryFailed);
            
            self.nameLable?.text = model?.user_info?.nickname;
        
        }
    }
    
    
    var imageView:UIImageView?
    
    var titlelabel:STLabel?
    
    var iconButton:STButton?
    
    var nameLable:STLabel?
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initSubview()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func initSubview() {
        
        self.backgroundColor = .clear;
        
        let cellWitdh = SCREEN_WIDTH / 2 - 12.5;
        self.imageView = UIImageView.init(frame: CGRect.init(x: 0, y: 0, width: cellWitdh - 0, height: cellWitdh - 0));
        self.imageView?.backgroundColor = .clear;
        self.imageView?.contentMode = .scaleAspectFill;
        self.imageView?.clipsToBounds = true;
        self.addSubview(self.imageView!);
        
        let grayView = UIView.init(frame: CGRect.init(x: 0, y: (self.imageView?.height)! - 50, width: (self.imageView?.width)!, height: 50));
        grayView.backgroundColor = UIColor.flatGrayDark.withAlphaComponent(0.4);
        self.addSubview(grayView);
        
        self.titlelabel = STLabel.init(frame: .init(x: 10, y: 3, width: (self.imageView?.width)! - 20, height: 12), text: "", textColor: .white, font: 12, isSizetoFit: false, textAlignment: .left);
        grayView.addSubview(self.titlelabel!);
        
        self.iconButton = STButton.init(frame: .init(x: 10, y: (self.titlelabel?.bottom)! + 3, width: 20, height: 20), title: "", titleColor: nil, titleFont: 0, cornerRadius: 10, backgroundColor: .clear, backgroundImage: PeopleImage, image: nil);
        grayView.addSubview(self.iconButton!);
        
        
        self.nameLable = STLabel.init(frame: .init(x: (self.iconButton?.right)! + 10, y: 0, width: (self.imageView?.width)! - 40, height: 10), text: "", textColor: .white, font: 10, isSizetoFit: false, textAlignment: .left);
        self.nameLable?.centerY = (self.iconButton?.centerY)!;
        grayView.addSubview(self.nameLable!);
        
    }
}
